package com.solution.admin.promotion.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.solution.admin.promotion.dao.PromotionRuleDiscountDao;
import com.solution.admin.promotion.entity.PromotionRuleDiscountEntity;
import com.solution.admin.promotion.service.PromotionRuleDiscountService;
import com.solution.common.dao.BaseDao;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;
import com.solution.common.service.impl.BaseServiceImpl;

/**
 * 活动规则-折扣信息service实现层
 * 
 * @author xu_cc
 * @date 2017-09-27 23:27:27
 */
@Service
public class PromotionRuleDiscountServiceImpl extends BaseServiceImpl<PromotionRuleDiscountEntity> implements PromotionRuleDiscountService {

    /**
     * 活动规则-折扣信息接口
     */
    @Autowired
    private PromotionRuleDiscountDao promotionRuleDiscountDao;

    protected BaseDao<PromotionRuleDiscountEntity> getDao() {
        return this.promotionRuleDiscountDao;
    }

    /**
     * 保存活动规则-折扣信息
     * 
     * @param promotionRuleDiscountEntity
     *            活动规则-折扣信息实体
     * @return Long 添加成功活动规则-折扣信息的ID
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    public long savePromotionRuleDiscount(PromotionRuleDiscountEntity promotionRuleDiscountEntity) {
        return promotionRuleDiscountDao.savePromotionRuleDiscount(promotionRuleDiscountEntity);
    }

    /**
     * 分页查询活动规则-折扣信息
     * 
     * @param pageParam
     *            分页参数
     * @param paramMap
     *            查询参数
     * @return PageBean 分页参数和分页数据
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    @Override
    public PageBean listPromotionRuleDiscountPage(PageParam pageParam, Map<String, Object> paramMap) {
        return promotionRuleDiscountDao.listPromotionRuleDiscountPage(pageParam, paramMap);
    }

    /**
     * 根据ID查询用户信息
     * 
     * @param id
     *            用户id
     * @return promotionRuleDiscountEntity 用户对象
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    public PromotionRuleDiscountEntity getPromotionRuleDiscountById(Long id) {
        return promotionRuleDiscountDao.getById(id.longValue());
    }

    /**
     * 更新用户
     * 
     * @param promotionRuleDiscountEntity
     *            用户实体
     * @return Long 更新是否成功，>1代表更新成功
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    @Override
    public int updatePromotionRuleDiscount(PromotionRuleDiscountEntity promotionRuleDiscountEntity) {
        return promotionRuleDiscountDao.updatePromotionRuleDiscount(promotionRuleDiscountEntity);
    }

    /**
     * 根据条件查询活动规则-折扣信息
     * 
     * @param param
     * @return 数据列表
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    @Override
    public List<PromotionRuleDiscountEntity> listPromotionRuleDiscount(Long promotionId) {
        return promotionRuleDiscountDao.listPromotionRuleDiscount(promotionId);
    }

    /**
     * 删除活动规则-折扣信息
     * 
     * @param
     * @return int 返回删除记录条数
     * @author xu_cc
     * @date 2017-09-27 23:27:27
     */
    public int deletetById(Long promotionId) {
        return promotionRuleDiscountDao.deleteById(promotionId);
    }

}
